<template>
	<view class="zhifubao">
		<view class="title">
			请绑定本人支付宝账号
		</view>
		<view class="inputList">
			<view class="inputBox">
				<view class="lable">
					真实姓名
				</view>
				<input class="inputitem" v-model="alipay_name" type="text" placeholder="请输入姓名" :disabled="flag">
			</view>
			<view class="inputBox">
				<view class="lable">
					支付宝账号
				</view>
				<input class="inputitem" v-model="alipay_account" type="text" placeholder="请输入支付宝账号" :disabled="flag">
			</view>
			<view class="inputBox" style="border-bottom: navajowhite;">
				<view class="lable">
					再次输入
				</view>
				<input class="inputitem" v-model="alipay_account1" type="text" placeholder="请再次输入支付宝账号" :disabled="flag">
			</view>

		</view>


		<view class="btns" @click="handleSava">
			完成
		</view>

		<view class="tixing">
			提醒：
		</view>
		<view class="texts">
			请确保添加的支付宝账号真实姓名与展示的真实姓名一致, 否则将影响您的提现到账情况!
		</view>

	</view>
</template>

<script>
	import {
		userinfo
	} from "@/api/api.js"
	export default {
		data() {
			return {
				alipay_name: "", //支付宝真实姓名
				alipay_account: "", //支付宝账号
				alipay_account1: "", //确认账号
				flag:false,
			}
		},
		onLoad() {
			if (!uni.getStorageSync("token")) {
				uni.reLaunch({
					url: "../login/index"
				})
				return
			}
			this.handleGetuserinfo()
		},
		methods: {
			async handleGetuserinfo() {
				let res = await userinfo()
				this.pageData = res.data
				console.log("用户信息", res)
				
				this.alipay_name = res.data.alipay_name 
				this.alipay_account = res.data.alipay_account
				this.alipay_account1 = res.data.alipay_account
				if(res.data.alipay_name == null || res.data.alipay_account ==''){
					this.flag = false
				}else{
					this.flag = true
				}
			},
			handleSava() {
				if(this.alipay_name == ""){
					uni.showToast({
						title: "请填写支付宝真实姓名",
						icon: "none",
						duration: 1500
					});
					return
				}
				if(this.alipay_account == ""){
					uni.showToast({
						title: "请填写支付宝账号",
						icon: "none",
						duration: 1500
					});
					return
				}
				if(this.alipay_account1 == ""){
					uni.showToast({
						title: "请填写确认支付宝账号",
						icon: "none",
						duration: 1500
					});
					return
				}
				if(this.alipay_account !=this.alipay_account1){
					uni.showToast({
						title: "支付宝账号输入不一致",
						icon: "none",
						duration: 1500
					});
					return
				}
				let data = {
					alipay_name:this.alipay_name,
					alipay_account:this.alipay_account
				}
				uni.setStorageSync("zhifubaoData",data)
                uni.navigateBack({delta:1})
			},
		}
	}
</script>

<style scoped lang="scss">
	page {
		width: 100%;
		min-height: 100%;
		background-color: #ffffff;
	}

	.zhifubao {
		width: 100%;
		padding: 30rpx;
		box-sizing: border-box;

		.title {
			font-size: 28rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 400;
			color: #707070;
			line-height: 48rpx;
		}

		.inputList {
			margin-top: 88rpx;

			.inputBox {
				width: 100%;
				display: flex;
				height: 88rpx;
				border-bottom: 1rpx solid #EDEDED;

				.lable {
					font-size: 24rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 400;
					color: #333333;
					line-height: 88rpx;
				}

				.inputitem {
					flex: 1;
					height: 88rpx;
					text-align: right;
					font-size: 24rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 400;
					line-height: 88rpx;
				}
			}
		}

		.btns {
			width: 542rpx;
			height: 80rpx;
			background: #04767C;
			border-radius: 512rpx 512rpx 512rpx 512rpx;
			font-size: 36rpx;
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
			line-height: 80rpx;
			text-align: center;
			margin: 0 auto;
			margin-top: 220rpx;
		}

		.tixing {
			font-size: 28rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 400;
			color: #FF6200;
			line-height: 28rpx;
			margin-top: 56rpx;
		}

		.texts {
			font-size: 24rpx;
			font-family: PingFang SC-Regular, PingFang SC;
			font-weight: 400;
			color: #FF6200;
			line-height: 32rpx;
			margin-top: 16rpx;
		}
	}
</style>